/*

   g10TryItJava -                Copyright (C) 2011 PH Informática, SA.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the  Free Software Foundation, either version 3 of the  License,  or
   (at your option) any later version.

   This  program  is distributed in  the hope that it will  be  useful,
   but  WITHOUT  ANY  WARRANTY; without even the  implied  warranty  of
   MERCHANTABILITY  or  FITNESS  FOR  A  PARTICULAR  PURPOSE.  See  the
   GNU General Public License for more details.

   You  should have received  a copy of  the GNU General Public License
   along with this program. If not, see <http://www.gnu.org/licenses/>.

*/
 package g10TryItl_java;

import java.awt.*;
import java.io.*;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

/**
 *
 * @author david
 */
public class cShowImage extends JPanel {
    //BufferedImage  image;
    Image image;

    public Image Img() {
        return image;
    }

    public cShowImage(byte[] imageData) throws Exception {
        ByteArrayInputStream bin = new ByteArrayInputStream( imageData );
        image=ImageIO.read(bin);
    }
    
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        // the size of the component
        Dimension d = getSize();
        // the internal margins of the component
        Insets i = getInsets();
        // draw to fill the entire component
        g.drawImage(image, i.left, i.top, d.width - i.left - i.right, d.height - i.top - i.bottom, this );
    }
}
